package TowDef.generic;

import java.awt.Point;
import java.util.ArrayList;

import javax.swing.ImageIcon;

public abstract class Tower {
	
	protected int id;
	protected int price;
	protected int range;
	protected int damage;
	protected int posX;
	protected int posY;
	protected int attackSpeed;
	protected ImageIcon towerImg;
	protected ArrayList<Point> path;
	
	public ImageIcon getTowerImg() {
		return towerImg;
	}
	public void setTowerImg(ImageIcon towerImg) {
		this.towerImg = towerImg;
	}
	public int getPrice() {
		return price;
	}
	public void setPrice(int price) {
		this.price = price;
	}
	public int getRange() {
		return range;
	}
	public void setRange(int range) {
		this.range = range;
	}
	public int getDamage() {
		return damage;
	}
	public void setDamage(int damage) {
		this.damage = damage;
	}
	public int getAttackSpeed() {
		return attackSpeed;
	}
	public void setAttackSpeed(int attackSpeed) {
		this.attackSpeed = attackSpeed;
	}
	
	public void attack(Enemy enemy)
	{
		enemy.setLife(enemy.getLife()-this.damage);
		if(enemy.getLife()<0)
			enemy.kill();
	}
	
	
	public void myRange(Map map)
	{
	for(int j = -range;j<this.range;j++)
	{
		for(int i = -range;i<this.range;i++)
		{
			if(map.getMapSquare()[this.getPosX()+i][this.getPosY()+j].isWay())
			{
				this.path.add(new Point(this.getPosX()+i, this.getPosY()+j));
			}

		}
	}
	}
	
	
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getPosX() {
		return posX;
	}
	public void setPosX(int posX) {
		this.posX = posX;
	}
	public int getPosY() {
		return posY;
	}
	public void setPosY(int posY) {
		this.posY = posY;
	}
	public ArrayList<Point> getPath() {
		return path;
	}
	public void setPath(ArrayList<Point> path) {
		this.path = path;
	}

}
